package com.linxz.video.videoplayer.utils;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

/**
 * @author Linxz
 * 创建日期：2019年10月15日 18:38
 * version：v4.5.4
 * 描述：
 */
public class Utils {


    /**
     * 获取view的屏幕属性
     *
     * @return
     */
    public static final String VIEW_INFO_EXTRA = "view_into_extra";
    public static final String PROPNAME_SCREENLOCATION_LEFT = "propname_sreenlocation_left";
    public static final String PROPNAME_SCREENLOCATION_TOP = "propname_sreenlocation_top";
    public static final String PROPNAME_WIDTH = "propname_width";
    public static final String PROPNAME_HEIGHT = "propname_height";

    public static Bundle getViewProperty(View view) {
        Bundle bundle = new Bundle();
        int[] screenLocation = new int[2];
        view.getLocationOnScreen(screenLocation); //获取view在整个屏幕中的位置
        bundle.putInt(PROPNAME_SCREENLOCATION_LEFT, screenLocation[0]);
        bundle.putInt(PROPNAME_SCREENLOCATION_TOP, screenLocation[1]);
        bundle.putInt(PROPNAME_WIDTH, view.getWidth());
        bundle.putInt(PROPNAME_HEIGHT, view.getHeight());

        Log.e("Utils", "Left: "
                + screenLocation[0]
                + " Top: "
                + screenLocation[1]
                + " Width: "
                + view.getWidth()
                + " Height: "
                + view.getHeight());
        return bundle;
    }

}
